/**
Company: Sarkar software technologys
WebSite: http://www.sarkar.cn
Author: yeganaaa
Date : 8/1/18
Time: 12:17 AM
 */

package com.ug_project.dict.engine.wordtable

import java.nio.channels.SeekableByteChannel

class WordTable(val channel: SeekableByteChannel) : LinkedHashMap<Int, WordRow>(){
    init {
        var position = 0
        while (position < channel.size()){
            val row = WordRow(this, position)
            this.put(row.unicode, row)
            position += row.size
        }
    }
    fun write(){
        var position = 0
        forEach {key, value ->
            value.startPosition = position
            value.write()
            position += value.size
        }
    }
}
